/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import Dao.AlunoDao;
import Dao.AlunoDaoImplJPA;
import Pojo.Aluno;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author thiago
 */
public class AlunoDaoImplJPATeste {
    
    public AlunoDaoImplJPATeste() {
    }
    
    @BeforeClass
    public static void setUpClass() {
    }
    
    @AfterClass
    public static void tearDownClass() {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }
    // TODO add test methods here.
    // The methods must be annotated with annotation @Test. For example:
    //
    // @Test
    // public void hello() {}
    
    @Test
    public void inserirDaCerto(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        Aluno aluno = new Aluno(1,"Thiago","09989403643");
        assertTrue(alunoDao.inserir(aluno));
    }
           
    @Test
    public void alterarDaCerto(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        Aluno aluno = new Aluno(1,"Testando","10238012830");
        assertTrue(alunoDao.alterar(aluno));
    }
    
    @Test
    public void alterarDaErrado(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        Aluno aluno = new Aluno(4,"Testando","10238012830");
        assertFalse(alunoDao.alterar(aluno));
    }
    
    @Test
    public void removerDaCerto(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        Aluno aluno = new Aluno(1,"Thiago","09989403643");
        assertTrue(alunoDao.remover(aluno));
    }
    
    @Test
    public void removerDaErrado(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        Aluno aluno = new Aluno(5,"Testando","10238012830");
        assertFalse(alunoDao.remover(aluno));
    }
    
    @Test
    public void pesquisarTodosDaCerto(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        Aluno aluno = new Aluno(2,"Teló","10238012830");
        alunoDao.inserir(aluno);
        assertNotSame(0,alunoDao.pesquisarTodos().size());
    }
    
    @Test
    public void pesquisarPorCpfDaCerto(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        assertNotNull(alunoDao.pesquisarPorCpf("10238012830"));
    }
    
    @Test
    public void pesquisarPorCpfDaErrado(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        assertNull(alunoDao.pesquisarPorCpf(""));
    }
    
    @Test
    public void pesquisarPorNomeDaCerto(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        assertNotSame(0,alunoDao.pesquisarPorNome("Teló").size());
    }
    
    @Test
    public void pesquisarPorNomeDaErrado(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        assertSame(0,alunoDao.pesquisarPorNome("Sirius").size());
    }
    
    @Test
    public void pesquisarPorIdDaCerto(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        assertNotNull(alunoDao.pesquisarPorId(2));
    }
    
    @Test
    public void pesquisarPorIdDaErrado(){
        AlunoDao alunoDao = new AlunoDaoImplJPA();
        assertNull(alunoDao.pesquisarPorId(1203));
    }
}